/*******************************************************************************
 *
 *    Copyright (c) Baina Info Tech Co. Ltd
 *
 *    Yoga
 *    
 *    NetworkHelper
 *    TODO File description or class description.
 *
 *    @author: zuochen
 *    @since:  2010-10-23
 *    @version: 1.0
 *
 ******************************************************************************/

package small.hero.entertaiment.radio.jiujie.version.zl.util;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

/**
 * 
 * @author zuochen
 * 
 */

public class NetworkHelper {

	public boolean isNetworkAvailable(Context context) {
		if (null == context) {
			return false;
		}
		ConnectivityManager connectivityManager = (ConnectivityManager) context
				.getSystemService(Context.CONNECTIVITY_SERVICE);
		if (connectivityManager != null) {
			NetworkInfo[] info = connectivityManager.getAllNetworkInfo();
			if (info != null) {
				for (int i = 0; i < info.length; i++) {
					if (info[i].getState() == NetworkInfo.State.CONNECTED) {
						return true;
					}
				}
			}
		}
		return false;
	}
}
